const Actions = require('./actions');
const DB = require('app/db.js');
import { Toast } from 'saltui';
import { Storage } from 'clientConfig/util/StoreData'
module.exports = Reflux.createStore({
    listenables: [Actions],
    data: {
    },

    onFetch: function (params, cb) {
        let t = this;
        DB.Teacher.edit_item_score({
            schoolId: Storage.get('user.schoolId'),
            scoreId: params.scoreId,
            placeId: params.placeId,
            entranceFlag: "detail"
        })
            .then((content) => {
                if (content && content.code == 1) {
                    let schoolId = content.check.schoolId;
                    let data = content.data;
                    t.data = Object.assign(t.data, data);
                    t.updateComponent();
                }else{
                    Toast.show({
                        type: 'error',
                        content: '系统异常'
                    });
                }

            })
            .catch(function (error) {
                Toast.show({
                    type: 'error',
                    content: '系统异常'
                });
            });
    },

    updateComponent: function () {
        this.trigger(this.data);
    }
});
